// --------------------------------------------------------------------------------------------------------------------
// <copyright file="VirtualMarketOrder.cs" company="Open Trader">
//   Copyright (c) David Denis (david.denis@systemathics.com)
// </copyright>
// <summary>
//   |  Open Trader - The Open Source Systematic Trading Platform
//   |
//   |  This program is free software: you can redistribute it and/or modify
//   |  it under the terms of the GNU General Public License as published by
//   |  the Free Software Foundation, either version 2 of the License, or
//   |  (at your option) any later version.
//   |
//   |  This program is distributed in the hope that it will be useful,
//   |  but WITHOUT ANY WARRANTY; without even the implied warranty of
//   |  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
//   |  GNU General Public License for more details.
//   |
//   |  You should have received a copy of the GNU General Public License
//   |  along with this program.  If not, see http://www.gnu.org/licenses
//   |
//   |  Up to date informations about Open Trader can be found at :
//   |    http://opentrader.org
//   |    http://opentrader.codeplex.com
//   |
//   |  For professional services, please visit us at :
//   |    http://www.systemathics.com
// </summary>
// --------------------------------------------------------------------------------------------------------------------

namespace Org.OpenTrader.Framework.Forge.Plugins
{
    #region Using Directives

    using System;

    using Org.OpenTrader.Framework.Forge.Enums;
    using Org.OpenTrader.Framework.Forge.Events;
    using Org.OpenTrader.Framework.Forge.Interfaces;

    #endregion

    /// <summary>
    /// An order masking a real order, When executing/matching the local quantity here is reduced
    /// </summary>
    public class VirtualMarketOrder
    {
        #region Constructors and Destructors

        /// <summary>
        /// Initializes a new instance of the <see cref="VirtualMarketOrder"/> class.
        /// </summary>
        /// <param name="order">
        /// The order.
        /// </param>
        /// <param name="handler">
        /// The handler.
        /// </param>
        public VirtualMarketOrder(IOrder order, RemotableEventHandler<OrderEventArgs> handler)
        {
            this.OrderID = order.ID;
            this.InstrumentID = order.InstrumentID;
            this.Dispatcher = handler;
            this.Quantity = order.Quantity;
            this.Price = order.Price;
            this.NewQuantity = 0;
            this.NewPrice = 0.0;
            this.Way = order.Way;
            this.Stamp = Timings.Now;
            this.Pending = true;
            this.Cancelling = false;
            this.Modifying = false;
        }

        #endregion

        #region Properties

        /// <summary>
        /// Gets or sets a value indicating whether Cancelling.
        /// </summary>
        public bool Cancelling { get; set; }

        /// <summary>
        /// Gets Dispatcher.
        /// </summary>
        public RemotableEventHandler<OrderEventArgs> Dispatcher { get; private set; }

        /// <summary>
        /// Gets InstrumentID.
        /// </summary>
        public Guid InstrumentID { get; private set; }

        /// <summary>
        /// Gets or sets a value indicating whether Modifying.
        /// </summary>
        public bool Modifying { get; set; }

        /// <summary>
        /// Gets or sets NewPrice.
        /// </summary>
        public double NewPrice { get; set; }

        /// <summary>
        /// Gets or sets NewQuantity.
        /// </summary>
        public int NewQuantity { get; set; }

        /// <summary>
        /// Gets OrderID.
        /// </summary>
        public Guid OrderID { get; private set; }

        /// <summary>
        /// Gets or sets a value indicating whether Pending.
        /// </summary>
        public bool Pending { get; set; }

        /// <summary>
        /// Gets or sets Price.
        /// </summary>
        public double Price { get; set; }

        /// <summary>
        /// Gets or sets Quantity.
        /// </summary>
        public int Quantity { get; set; }

        /// <summary>
        /// Gets Stamp.
        /// </summary>
        public DateTime Stamp { get; private set; }

        /// <summary>
        /// Gets Order Way.
        /// </summary>
        public EOrderWay Way { get; private set; }

        #endregion
    }
}